package com.zscat.mallplus.vo;

import java.util.List;

public class PageInfo<T> {
    /**
     * 默认分页索引
     */
    public static final int DEFAULT_PAGE_INDEX = 1; // 默认分页索引
    /**
     * 默认分页大小
     */
    public static final int DEFAULT_PAGE_SIZE = 10; // 默认分页大小
    /**
     * 没有更多
     */
    public static final int MORE_NO = 0;
    /**
     * 有更多
     */
    public static final int MORE_YES = 1;

    private Integer hasMore; // 0 没有更多  1有更多

    private Integer pageIndex;

    private Integer total;

    private Integer pageSize; // 当前页面有多少条

    private List<T> recordList; // 本页的数据列表

    public PageInfo() {

    }

    public PageInfo(Integer pageIndex, Integer pageSize, List<T> recordList) {
        this.pageIndex = pageIndex;
        this.pageSize = pageSize;
        this.recordList = recordList;
        this.hasMore = recordList.size() == pageSize ? 1 : 0;
    }

    public PageInfo(Integer total, Integer pageIndex, Integer pageSize, List<T> recordList) {
        this.total = total;
        this.pageIndex = pageIndex;
        this.pageSize = pageSize;
        this.recordList = recordList;
        this.hasMore = recordList.size() == pageSize ? 1 : 0;
    }


    public Integer getHasMore() {
        return hasMore;
    }

    public void setHasMore(Integer hasMore) {
        this.hasMore = hasMore;
    }

    public Integer getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(Integer pageIndex) {
        this.pageIndex = pageIndex;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public List<T> getRecordList() {
        return recordList;
    }

    public void setRecordList(List<T> recordList) {
        this.recordList = recordList;
    }

    public Integer getTotal() {
        return total;
    }

    public void setTotal(Integer total) {
        this.total = total;
    }

    @Override
    public String toString() {
        return "PageInfo [hasMore=" + hasMore + ", pageSize=" + pageSize
                + ", recordList=" + recordList + "]";
    }

}
